﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuanLyTiemVang.DAO
{
    class BaoCaoTonDAO
    {
        private static QUANLYTIEMVANGEntities dbContext = new QUANLYTIEMVANGEntities();
        public static List<BAOCAOTON> SelectAllBaoCaoTon()
        {
            var query = from d in dbContext.BAOCAOTONs
                        select d;

            return query.ToList();
        }
        public static void Insert(BAOCAOTON bct)
        {
            dbContext.BAOCAOTONs.Add(bct);
            dbContext.SaveChanges();
        }

        
        public static BAOCAOTON SelectLast()
        {
            var query = from d in dbContext.BAOCAOTONs
                        select d;

            if (query.ToList().Count == 0)
                return null;

            return query.OrderByDescending(m => m.MaBaoCaoTon).FirstOrDefault();
        }
    }
}
